<?php

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class PermissionRoleTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //分配默认角色权限
        #model-index
        $index = [
            'user-index',
            'role-index',
            'permission-index',
            'ogz-index',
            'qyapp-index',
            'vuls-index',
            'cate-index',
            'level-index',
            'log-index'
        ];
        $permissionsIds = DB::table('permissions')
            ->select('id')
            ->whereIn('code',$index)
            ->get();

        $datas = [];
        $i = 0;
        foreach ($permissionsIds as $item){
            $datas[$i]['permission_id'] = $item->id;
            $datas[$i]['role_id'] = 2;
            $i++;
        }
        DB::table('permission_role')->insert($datas);
    }
}
